<!--
* 开源版本请务必保留此注释头信息，若删除捷码开源〔GEMOS〕官方保留所有法律责任追究！
* 本软件受国家版权局知识产权以及国家计算机软件著作权保护（登记号：2018SR503328）
* 不得恶意分享产品源代码、二次转售等，违者必究。
* Copyright (c) 2020 gemframework all rights reserved.
* http://www.gemframework.com
* 版权所有，侵权必究！
-->
<!DOCTYPE html>
<html lang="zh-cn" class="fullscreen-bg" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/links :: common_header(~{::title},~{::style},~{})">
    <title>个人中心</title>
    <style>
        /* 用户信息 */
        .user-info-head {
            width: 110px;
            height: 110px;
            line-height: 110px;
            position: relative;
            display: inline-block;
            border: 2px solid #eee;
            border-radius: 50%;
            overflow: hidden;
            cursor: pointer;
            margin: 0 auto;
        }

        .user-info-head:hover:after {
            content: '\e681';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            color: #fff;
            background-color: rgba(0, 0, 0, 0.3);
            font-size: 28px;
            padding-top: 2px;
            font-style: normal;
            font-family: layui-icon;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }

        .user-info-head img {
            width: 110px;
            height: 110px;
        }

        .user-info-list-item {
            position: relative;
            padding-bottom: 8px;
        }

        .user-info-list-item > .layui-icon {
            position: absolute;
        }

        .user-info-list-item > p {
            padding-left: 30px;
        }

        .layui-line-dash {
            border-bottom: 1px dashed #ccc;
            margin: 15px 0;
        }

        /* 基本信息 */
        #userInfoForm .layui-form-item {
            margin-bottom: 25px;
        }

        /* 账号绑定 */
        .user-bd-list-item {
            padding: 14px 60px 14px 10px;
            border-bottom: 1px solid #e8e8e8;
            position: relative;
        }

        .user-bd-list-item .user-bd-list-lable {
            color: #333;
            margin-bottom: 4px;
        }

        .user-bd-list-item .user-bd-list-oper {
            position: absolute;
            top: 50%;
            right: 10px;
            margin-top: -8px;
            cursor: pointer;
        }

        .user-bd-list-item .user-bd-list-img {
            width: 48px;
            height: 48px;
            line-height: 48px;
            position: absolute;
            top: 50%;
            left: 10px;
            margin-top: -24px;
        }

        .user-bd-list-item .user-bd-list-img + .user-bd-list-content {
            margin-left: 68px;
        }
    </style>
</head>
<body>
<!-- 加载动画 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <!-- 左 -->
        <div class="layui-col-sm12 layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-body" style="padding: 25px;">
                    <div class="text-center layui-text">
                        <div class="user-info-head" id="userInfoHead">
                            <img src="../../coral/images/avatar/user3-160x160.jpg" alt=""/>
                        </div>
                        <h2 style="padding-top: 20px;">
                            <span th:text="${session.session_user.username}"></span>
                        </h2>
                        <p style="padding-top: 8px;">匠心出品，专注于用户体验</p>
                    </div>
                    <div class="layui-text" style="padding-top: 30px;">
                        <div class="user-info-list-item">
                            <i class="layui-icon layui-icon-username"></i>
                            <p><span th:text="${session.session_user.realname}"></span></p>
                        </div>
                        <div class="user-info-list-item">
                            <i class="layui-icon layui-icon-release"></i>
                            <p><span th:text="${session.session_user.sex == 0 ? '男':'女'}"></span></p>
                        </div>
                        <div class="user-info-list-item">
                            <i class="layui-icon layui-icon-cellphone-fine"></i>
                            <p><span th:text="${session.session_user.phone}"></span></p>
                        </div>
                    </div>
                    <div class="layui-line-dash"></div>
                    <h3>标签</h3>
                    <div class="layui-badge-list" style="padding-top: 6px;">
                        <span class="layui-badge layui-bg-gray">资深架构</span>
                        <span class="layui-badge layui-bg-gray">专注设计</span>
                        <span class="layui-badge layui-bg-blue">前端大牛</span>
                    </div>
                    <div class="layui-badge-list" style="padding-top: 6px;">
                        <span class="layui-badge layui-bg-gray">快速开发</span>
                        <span class="layui-badge layui-bg-gray">清新简洁</span>
                        <span class="layui-badge layui-bg-orange">工匠精神</span>
                    </div>
                </div>
            </div>
        </div>
        <!-- 右 -->
        <div class="layui-col-sm12 layui-col-md9">
            <div class="layui-card">
                <!-- 选项卡开始 -->
                <div class="layui-tab layui-tab-brief" lay-filter="userInfoTab">
                    <ul class="layui-tab-title">
                        <li class="layui-this">基本信息</li>
                        <li>账号绑定</li>
                    </ul>
                    <div class="layui-tab-content">
                        <!-- tab1 -->
                        <div class="layui-tab-item layui-show">
                            <form class="layui-form" id="userInfoForm" lay-filter="userInfoForm"
                                  style="max-width: 400px;padding: 25px 10px 0 0;">
                                <input name="id" type="hidden"/>
                                <div class="layui-form-item">
                                    <label class="layui-form-label layui-form-required">真实姓名:</label>
                                    <div class="layui-input-block">
                                        <input name="realname" class="layui-input" lay-verify="required" required/>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label layui-form-required">电子邮箱:</label>
                                    <div class="layui-input-block">
                                        <input name="email" class="layui-input" lay-verify="email" required/>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">手机号码:</label>
                                    <div class="layui-input-block">
                                        <input name="phone" lay-verify="phone" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">办公电话:</label>
                                    <div class="layui-input-block">
                                        <input name="phone1" value="010" class="layui-input" style="width: 60px;"/>
                                        <div style="position: absolute;left: 70px;right: 0;top: 0;">
                                            <input name="phone2" value="26668888" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">联系地址:</label>
                                    <div class="layui-input-block">
                                        <input name="address" class="layui-input"/>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-filter="userInfoSubmit" lay-submit>更新基本信息
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- tab1 -->
                        <div class="layui-tab-item" style="padding-bottom: 20px;">
                            <div class="user-bd-list layui-text">
                                <div class="user-bd-list-item">
                                    <div class="user-bd-list-lable">密保手机</div>
                                    <div class="user-bd-list-text">已绑定手机：133****2315</div>
                                    <a class="user-bd-list-oper">修改</a>
                                </div>
                                <div class="user-bd-list-item">
                                    <div class="user-bd-list-lable">密保邮箱</div>
                                    <div class="user-bd-list-text">已绑定邮箱：gemframe@163.com</div>
                                    <a class="user-bd-list-oper">修改</a>
                                </div>
                                <div class="user-bd-list-item">
                                    <div class="user-bd-list-img">
                                        <i class="layui-icon layui-icon-login-qq"
                                           style="color: #3492ED;font-size: 48px;"></i>
                                    </div>
                                    <div class="user-bd-list-content">
                                        <div class="user-bd-list-lable">绑定QQ</div>
                                        <div class="user-bd-list-text">当前未绑定QQ账号</div>
                                    </div>
                                    <a class="user-bd-list-oper">绑定</a>
                                </div>
                                <div class="user-bd-list-item">
                                    <div class="user-bd-list-img">
                                        <i class="layui-icon layui-icon-login-wechat"
                                           style="color: #4DAF29;font-size: 48px;"></i>
                                    </div>
                                    <div class="user-bd-list-content">
                                        <div class="user-bd-list-lable">绑定微信</div>
                                        <div class="user-bd-list-text">当前未绑定绑定微信账号</div>
                                    </div>
                                    <a class="user-bd-list-oper">绑定</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- //选项卡结束 -->
            </div>
        </div>
    </div>
</div>

<!-- js部分 -->
<div th:replace="common/scripts :: common"></div>
<script th:inline="javascript">
    layui.use(['layer', 'form', 'element', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var element = layui.element;
        var admin = layui.admin;

        /* 选择头像 */
        $('#userInfoHead').click(function () {
            admin.cropImg({
                imgSrc: $('#userInfoHead>img').attr('src'),
                onCrop: function (res) {
                    $('#userInfoHead>img').attr('src', res);
                    parent.layui.jquery('.layui-layout-admin>.layui-header .layui-nav img.layui-nav-img').attr('src', res);
                }
            });
        });

        // 回显表单数据
        $.get('user/info', {id:[[${session.session_user.id}]]}, function (res) {
            if (res.code === 0) {
                form.val('userInfoForm',res.data);
            } else {
                layer.msg(res.msg, {icon: 2});
            }
        }, 'json');

        // 表单提交事件
        form.on('submit(userInfoSubmit)', function (data) {
            data.field.tel = data.field.phone1+data.field.phone2;
            var loadIndex = layer.load(2);
            if(data.field.password === ""){
                delete data.field.password;
            }
            $.post('user/update', data.field, function (res) {
                layer.close(loadIndex);
                if (res.code === 0) {
                    layer.msg(res.msg, {icon: 1});
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'json');
            return false;
        });
    });
</script>
</body>
</html>